-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: remove tracing::info
usage
#578
base: main
Are you sure you want to change the base?
Conversation
β¦-zksync into db/remove-tracing-info
β¦-zksync into db/remove-tracing-info
@itegulov based on the proposal feedback, I turned off For revert / halts and logs in formatter.rs those will be subsequently updated in #571 and #577. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly LGTM
crates/common/Cargo.toml
Outdated
|
||
[dependencies] | ||
anstream.workspace = true | ||
anstyle.workspace = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: missing newline
crates/common/src/shell.rs
Outdated
let prefix = if self.should_color() { | ||
format!("{}Warning:{} ", WARN, Reset) | ||
} else { | ||
"Warning: ".to_string() | ||
}; | ||
self.println_err(&format!("{}{}", prefix, msg)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit (here and in other places): extra allocations seem unjustified, we could easily just write to stdout/stderr.
Not that it's a performance concern, just feels not very clean. In that regard, I like foundry approach more.
crates/core/src/node/eth.rs
Outdated
@@ -55,7 +56,7 @@ impl InMemoryNode { | |||
message | |||
); | |||
|
|||
tracing::info!("{}", pretty_message.on_red()); | |||
sh_eprintln!("\n{}", pretty_message.on_red()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and in other places: why do we need \n
to be inserted manually?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for readability, more opinionated than anything. For example, since we are still printing tx summary currently, without \n
in some places you get:
β
[SUCCESS] Hash: 0x9c159398838efc27c9b8e0f858d39914c2d57a28e264a21124898f7ce0f99973
Initiator: 0xbd29a1b981925b94eec5c4f1125af02a2ec4d1ca
Payer: 0xbd29a1b981925b94eec5c4f1125af02a2ec4d1ca
Gas Limit: 317_069 | Used: 317_069 | Refunded: 0
Paid: 0.0000143474 ETH (317069 gas * 0.04525000 gwei)
Refunded: 0.0000000000 ETH
execution reverted: Ownable: caller is not the owner
Traces:
[18748] RichAccount::validateTransaction(0x3a01cb7f742913bc3ad049e8d38aa733b6b5109900bfc32050b34553fcec9f54, 0xa4da2b8671d03015e54f04c404bcc833ad27ce876378f46c5de0f7fe0cede56a, (113, 310456771025820669616026695872740475403597889609 [3.104e47], 32774 [3.277e4], 1073938 [1.073e6], 50000 [5e4], 45250000 [4.525e7], 45250000 [4.525e7], 0, 4, 0, [0, 0, 0, 0], 0x9c4d535b0000000000000000000000000000000000000000000000000000000000000000010001556e69cb167b6cd0feb302b363b7045e5a8d960f60593983b2690bad39000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d48656c6c6f2c20776f726c642100000000000000000000000000000000000000, 0x633c8fc52cea7cb7d52edf9987fc2e090a39071e5f61cf81cadbf56653557d4f14fa7d4307f2164b37e852a04400db1165490f7d2febf7c6461fad44d186750f1c, [0x010001556e69cb167b6cd0feb302b363b7045e5a8d960f60593983b2690bad39], 0x, 0x))
ββ β [Success] 202bcce700000000000000000000000000000000000000000000000000000000
[8691] RichAccount::payForTransaction(0x3a01cb7f742913bc3ad049e8d38aa733b6b5109900bfc32050b34553fcec9f54, 0xa4da2b8671d03015e54f04c404bcc833ad27ce876378f46c5de0f7fe0cede56a, (113, 310456771025820669616026695872740475403597889609 [3.104e47], 32774 [3.277e4], 1073938 [1.073e6], 50000 [5e4], 45250000 [4.525e7], 45250000 [4.525e7], 0, 4, 0, [0, 0, 0, 0], 0x9c4d535b0000000000000000000000000000000000000000000000000000000000000000010001556e69cb167b6cd0feb302b363b7045e5a8d960f60593983b2690bad39000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d48656c6c6f2c20776f726c642100000000000000000000000000000000000000, 0x633c8fc52cea7cb7d52edf9987fc2e090a39071e5f61cf81cadbf56653557d4f14fa7d4307f2164b37e852a04400db1165490f7d2febf7c6461fad44d186750f1c, [0x010001556e69cb167b6cd0feb302b363b7045e5a8d960f60593983b2690bad39], 0x, 0x))
ββ β [Success]
[43918] RichAccount::executeTransaction(0x3a01cb7f742913bc3ad049e8d38aa733b6b5109900bfc32050b34553fcec9f54, 0xa4da2b8671d03015e54f04c404bcc833ad27ce876378f46c5de0f7fe0cede56a, (113, 310456771025820669616026695872740475403597889609 [3.104e47], 32774 [3.277e4], 1073938 [1.073e6], 50000 [5e4], 45250000 [4.525e7], 45250000 [4.525e7], 0, 4, 0, [0, 0, 0, 0], 0x9c4d535b0000000000000000000000000000000000000000000000000000000000000000010001556e69cb167b6cd0feb302b363b7045e5a8d960f60593983b2690bad39000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d48656c6c6f2c20776f726c642100000000000000000000000000000000000000, 0x633c8fc52cea7cb7d52edf9987fc2e090a39071e5f61cf81cadbf56653557d4f14fa7d4307f2164b37e852a04400db1165490f7d2febf7c6461fad44d186750f1c, [0x010001556e69cb167b6cd0feb302b363b7045e5a8d960f60593983b2690bad39], 0x, 0x))
ββ [12412] β new <unknown>@0x4b5df730c2e6b28e17013a1485e5d9bc41efe021
β ββ emit OwnershipTransferred(param0: 0x0000000000000000000000000000000000000000, param1: RichAccount: [0x36615Cf349d7F6344891B1e7CA7C72883F5dc049])
β ββ β [Success] 64 bytes of code
ββ β [Success] 00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good conceptually, some logs were misconverted though IMHO
crates/config/src/config.rs
Outdated
sh_println!("Genesis Timestamp"); | ||
sh_println!("========================"); | ||
sh_println!("{}", self.get_genesis_timestamp().to_string().green()); | ||
sh_println!("\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something I have wanted to do for a while is to refactor this file to print using raw strings instead, like this:
sh_print!(
r#"
Genesis Timestamp
========================
{}
"#,
self.get_genesis_timestamp().to_string().green()
);
The code indents won't be pretty but it will be easy to see what each table looks like (and ensure that fields are properly aligned etc). Can be done in a separate PR ofc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahhh this is much better π
crates/core/src/formatter.rs
Outdated
sh_println!("\n{} [{}] Hash: {:?}", emoji, status, tx.hash()); | ||
sh_println!("Initiator: {:?}", tx.initiator_account()); | ||
sh_println!("Payer: {:?}", tx.payer()); | ||
sh_println!( | ||
"Gas Limit: {} | Used: {} | Refunded: {}", | ||
to_human_size(tx.gas_limit()), | ||
to_human_size(used_gas), | ||
to_human_size(tx_result.refunds.gas_refunded.into()) | ||
); | ||
tracing::info!( | ||
sh_println!( | ||
"Paid: {:.10} ETH ({} gas * {})", | ||
paid_in_eth, | ||
used_gas, | ||
format_gwei(l2_gas_price.into()) | ||
); | ||
tracing::info!("Refunded: {:.10} ETH", refunded_in_eth); | ||
sh_println!("Refunded: {:.10} ETH", refunded_in_eth); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here potentially. Note: you can use variable in interpolation directly and named parameters like this: sh_println!("{argument}", argument = "test")
. See fmt
tracing::debug!( | ||
"set code: address={:?}, bytecode_hash={:?}", | ||
address, | ||
BytecodeHash::for_bytecode(&bytecode).value() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order was correct before, this is how you output structured logs/events in tracing. See docs
latest_number, | ||
latest_hash, | ||
latest_batch_number, | ||
latest_timestamp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
Err(Web3Error::SubmitTransactionError(pretty_message, data)) | ||
} | ||
ExecutionResult::Halt { reason } => { | ||
tracing::info!("{}", format!("Unable to estimate gas for the request with our suggested gas limit of {}. The transaction is most likely unexecutable. Breakdown of estimation:", suggested_gas_limit + overhead).red()); | ||
tracing::info!( | ||
tracing::debug!("{}", format!("Unable to estimate gas for the request with our suggested gas limit of {}. The transaction is most likely unexecutable. Breakdown of estimation:", suggested_gas_limit + overhead).red()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and in other places: no need to colorize tracing logs, then format!
arguments can be inlined
@@ -111,7 +112,7 @@ impl NodeExecutor { | |||
// Reply to sender if we can, otherwise hold result for further processing | |||
let result = if let Some(reply) = reply { | |||
if let Err(result) = reply.send(result) { | |||
tracing::info!("failed to reply as receiver has been dropped"); | |||
sh_eprintln!("failed to reply as receiver has been dropped"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave reply failures as tracing
logs. If receiver was dropped then it (likely) means network connection with users client (ethers, hardhat script etc) got severed for some reason. Not super actionable from user's side.
crates/core/src/node/pool.rs
Outdated
"Failed to send transaction notification because channel is full", | ||
sh_warn!( | ||
"Failed to send transaction notification because channel is full: {}", | ||
tx_hash, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
@@ -139,7 +139,6 @@ impl InMemoryNode { | |||
if let Some(bytecode) = self.storage.load_factory_dep_alt(hash).await? { | |||
return Ok(Some(bytecode)); | |||
} | |||
println!("Nope"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What π»
tracing::info!
in favour of shell wrapper and macro usage. A simplified version of Foundry's shell wrapper.Why β
tracing::info!
with stdoutΒ #435Evidence π·
Include screenshots, screen recordings, or
console
output here demonstrating that your changes work as intended